<?php
	class Article_model extends CI_Model {
		public $table_name = "article";
		 public function get_All(){
	        $query = $this->db->get($this->table_name);
	        return $query->result();	       
    	}
    	public function get_One($id){
    		$query = $this->db->where("id",$id)->get($this->table_name);
	        return $query->row();
    	}
    	public function get_Catalog($id){
    		$query = $this->db->where("catalog_id",$id)->get($this->table_name);
	        return $query->result();
    	}
    	public function view_once($id){
    		$query = $this->db->query( "update $this->table_name set `view` = view + 1 where `id` = $id");
    	}
        public function count_All(){
            return $this->db->count_all_results($this->table_name);
            // return $query->result();        
        }
        public function get_by_page($page,$page_size){
            $offset = ($page-1)*$page_size;
             $query = $this->db->limit($page_size,$offset)->order_by('id', 'DESC')->get($this->table_name);
            // $query = $this->db->get($this->table_name,$page_size,$offset);
            return $query->result(); 
        } 
	}
?>